home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / GSOS / TN.GSOS.012 < prev    next >
Encoding:
Text File  |  1990-09-21  |  5.1 KB  |  110 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. GS/OS
  7. #12:    All About Notify Procs
  8.  
  9. Written by:    Matt Deatherage                                 September 1990
  10.  
  11. This Technical Note discusses the GS/OS notification procedure new to System 
  12. Software 5.0 and enhances the discussion of these procedures in the 
  13. Addison-Wesley GS/OS Reference.
  14. _____________________________________________________________________________
  15.  
  16.  
  17. Why Do I Want To Be Notified?
  18.  
  19. GS/OS notification procedures (or "notify procs") are handy ways to let the 
  20. operating system tell you when interesting things are happening.  As 
  21. documented in GS/OS Reference, they can tell you when you're switching to 
  22. ProDOS 8 (and back), when disks are inserted or ejected, when GS/OS is shut 
  23. down, and even when a change occurs to a volume.
  24.  
  25. However, getting these notifications is not as simple as installing a 
  26. procedure.  Some behaviors are due to the way device drivers are designed and 
  27. some are due to the design of GS/OS or device hardware.  This Note discusses a 
  28. few slightly unusual situations you can encounter when dealing with 
  29. notification procedures.
  30.  
  31.  
  32. I Get "Parameter out of range," and There's Only One Parameter
  33.  
  34. It seems incongruous to get error $0053 ("Parameter out of range") when 
  35. there's only one parameter, a pointer to the notification procedure.  However, 
  36. GS/OS checks the procedure header to ensure consistency.  In particular, the 
  37. flags field must not have any of the reserved bits set.  Having any bits other 
  38. than one through six set results in error $53; it ensures you do not get 
  39. strange behavior or are not passed values you cannot comprehend.
  40.  
  41.  
  42. I'm Not Getting Notified
  43.  
  44. You've written your notification procedure correctly and tested it, but when 
  45. you run your application you can eject and insert disks until your arm falls 
  46. off and your code is never called.
  47.  
  48. This is a side effect of the design of most Apple II peripherals--no hardware 
  49. interrupt is generated when you eject a disk.  Without an interrupt to grab 
  50. the CPU's attention, the drive just sits there until someone actually asks the 
  51. drive if a disk is present.
  52.  
  53. Well-designed GS/OS drivers look to see if a disk has been switched every time 
  54. they get control and call the System Service routine SET_DISKSW, which in turn 
  55. causes the notification procedures to be told the disk has been switched.  
  56. However, the driver cannot set this chain in motion until it gets control.
  57.  
  58. The easiest way to do this is to loop through all on-line devices, issuing a 
  59. device call to each in turn.  When the driver gets control, it starts the ball 
  60. rolling.  Note that you must make a device call that actually causes driver 
  61. code to be executed.  This includes all the application level device calls 
  62. with less than two parameters, except DRename and DInfo (the third parameter 
  63. is a block count, which causes a Driver_Status call to the driver).  These 
  64. calls are handled entirely by the Device Manager without actually transferring 
  65. control to any driver code.  DStatus with a transferCount = 2 is a good 
  66. choice.
  67.  
  68.  
  69. I Get Notified About Insertion at Weird Times
  70.  
  71. When coming back to GS/OS from ProDOS 8, you get "insertion" notification even 
  72. though no disks have actually been inserted.  This is done for you by most 
  73. drivers, which pretend that any media in the device has just come online at 
  74. driver startup time--which is true as far as any application is concerned.
  75.  
  76.  
  77. General Truths
  78.  
  79. Be careful when installing notification procedures from an application.  
  80. Applications either go away or are made purgeable when they quit, and that 
  81. means your notification procedure can get disposed.  GS/OS tries to call the 
  82. address anyway, and this is generally a bad idea.  Make sure you remove all 
  83. notification procedures before their code goes away.
  84.  
  85. Even though you have to poll to ensure you get disk insertion and ejection 
  86. events, it's still useful to install notification procedures.  The 
  87. notification queue allows everyone who's interested in GS/OS events to be 
  88. notified about them.  Check the "disk has been switched" bit of the status 
  89. word is not suitable, because this bit is only set once.  If a desk accessory 
  90. makes a status call to a switched device, it sees the "disk has been switched" 
  91. bit and your application does not, so use the notification queue.
  92.  
  93. Operating system calls (i.e., Write) can generate volume changed events during 
  94. execution; therefore, GS/OS could be busy when it calls your notification 
  95. procedure.  Volume changed events are not necessarily generated immediately.  
  96. The AppleShare FST checks for volume changes approximately every 10 seconds, 
  97. but it only generates these events for a given volume if it contains an open 
  98. folder.
  99.  
  100. GS/OS can call your notification procedure from inside an interrupt, so make 
  101. it short and sweet.  One approach is setting a flag which you can check 
  102. periodically from your main code; when the flag is set, you can process the 
  103. event and clear the flag.
  104.  
  105.  
  106. Further Reference
  107. _____________________________________________________________________________
  108.   o  GS/OS Reference
  109.  
  110.